package com.wetao.lib_common.compare;

import com.wetao.lib_common.bean.response.StudentExamGridInfoResp;
import com.wetao.lib_common.bean.response.StudentExamGridInfoResp_grids;
import com.wetao.lib_common.greendao.model.PenOffLineGridInfo;
import com.wetao.lib_common.greendao.model.PenOffLineGridInfoChild;
import com.wetao.lib_common.utils.CompareUtil;

import java.util.List;

public class ComparePenOffLinePage {
    public static boolean comparePage(StudentExamGridInfoResp left, PenOffLineGridInfo right) {
        if(left == null && right == null) {
            return true;
        } else if(left == null || right == null) {
            return false;
        } else if(!CompareUtil.compareIntEqual(left.getExamPageNumber(), right.getExamPageNumber())) {
            return false;
        } else if(!CompareUtil.compareIntEqual(left.getExamPageNo(), right.getExamPageNo())) {
            return false;
        } else if(!CompareUtil.compareIntEqual(left.getIsAnswerSheet(), right.getIsAnswerSheet())) {
            return false;
        } else if(!CompareUtil.compareIntEqual(left.getSourceType(), right.getSourceType())) {
            return false;
        } else if(!CompareUtil.compareIntEqual(left.getExamId(), right.getExamId())) {
            return false;
        } else if(!CompareUtil.compareStrEqual(left.getExamName(), right.getExamName())) {
            return false;
        } else if(!CompareUtil.compareStrEqual(left.getAssistantName(), right.getAssistantName())) {
            return false;
        } else if(!CompareUtil.compareStrEqual(left.getBookName(), right.getBookName())) {
            return false;
        }

        return true;
    }

    public static boolean comparePageGird(List<PenOffLineGridInfoChild> left, List<StudentExamGridInfoResp_grids> right) {
        if(left == null && right == null) {
            return true;
        } else if(left == null || right == null) {
            return false;
        } else if(left.size() != right.size()) {
            return false;
        }

        for (PenOffLineGridInfoChild item_db : left) {
            boolean isTrue = false;
            for (StudentExamGridInfoResp_grids item_resp : right) {
                if (item_db.getGridId().intValue() == item_resp.getGridId().intValue()) {
                    if (CompareUtil.compareIntEqual(item_db.getGridType(), item_resp.getGridType())
                        && CompareUtil.compareIntEqual(item_db.getKnowledgeMapOutlineContentId(), item_resp.getKnowledgeMapOutlineContentId())
                        && CompareUtil.compareIntEqual(item_db.getContentType(), item_resp.getContentType())
                        && CompareUtil.compareIntEqual(item_db.getExamId(), item_resp.getExamId())
                        && CompareUtil.compareStrEqual(item_db.getExamName(), item_resp.getExamName())
                        && CompareUtil.compareIntEqual(item_db.getIsExam(), item_resp.getIsExam())
                        && CompareUtil.compareIntEqual(item_db.getQuestionId(), item_resp.getQuestionId())
                        && CompareUtil.compareStrEqual(item_db.getQuestion(), item_resp.getQuestion())
                        && CompareUtil.compareStrEqual(item_db.getFileName(), item_resp.getFileName())
                        && CompareUtil.compareFloatEqual(item_db.getStartX(), item_resp.getStartX())
                        && CompareUtil.compareFloatEqual(item_db.getStartY(), item_resp.getStartY())
                        && CompareUtil.compareFloatEqual(item_db.getEndX(), item_resp.getEndX())
                        && CompareUtil.compareFloatEqual(item_db.getEndY(), item_resp.getEndY())
                    ) {
                        isTrue = true;
                        break;
                    }
                }
            }
            if(!isTrue) {
                return false;
            }
        }
        return true;
    }
}
